home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Technical Documentation / Sample Code / DTS.Lib & Samples / DTS.Draw / TOvalObj.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-22  |  3.3 KB  |  160 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:        TOvalObj.c
  5. ** Written by:    Eric Soldan
  6. **
  7. ** Copyright © 1992 Apple Computer, Inc.
  8. ** All rights reserved.
  9. */
  10.  
  11. /* See the files "=How to write your app" and "=Using TreeObj.c" for information
  12. ** on this function. */
  13.  
  14. /* This file implements the messages for the oval object.  Many of the messages
  15. ** can be handled by the rect object, as they deal with a rect structure.  Only
  16. ** a few of them are oval-specific. */
  17.  
  18. /* It would seem that you would want a custom hit-test message handler here, but
  19. ** the rect object first checks to see if the hit is within the bounding box of
  20. ** the object, and if so, it then calls the object to return the region.  This
  21. ** allows the rect object to generically handle hit-testing. */
  22.  
  23.  
  24.  
  25. /*****************************************************************************/
  26.  
  27.  
  28.  
  29. #include "App.h"            /* Get the application includes/typedefs, etc.    */
  30. #include "App.Common.h"        /* Get the stuff in common with rez.            */
  31. #include "App.protos.h"        /* Get the prototypes for the application.        */
  32.  
  33. #ifndef __OSEVENTS__
  34. #include <OSEvents.h>
  35. #endif
  36.  
  37. #ifndef __OSUTILS__
  38. #include <OSUtils.h>
  39. #endif
  40.  
  41. #ifndef __QUICKDRAW__
  42. #include <Quickdraw.h>
  43. #endif
  44.  
  45. #ifndef __STRING__
  46. #include <String.h>
  47. #endif
  48.  
  49. #ifndef __TREEOBJ2__
  50. #include "TreeObj2.h"
  51. #endif
  52.  
  53. #ifndef __UTILITIES__
  54. #include "Utilities.h"
  55. #endif
  56.  
  57.  
  58.  
  59. #pragma segment DrawObjects
  60. long    TOvalObj(TreeObjHndl hndl, short message, long data)
  61. {
  62.     Rect        rct;
  63.     RgnHandle    rgn;
  64. #if VH_VERSION
  65.     char        *cptr;
  66. #endif
  67.  
  68.     switch (message) {
  69.         case INITMESSAGE:
  70.         case FREEMESSAGE:
  71.         case COPYMESSAGE:
  72.         case UNDOMESSAGE:
  73.         case CONVERTMESSAGE:
  74.         case FREADMESSAGE:
  75.         case FWRITEMESSAGE:
  76.         case HREADMESSAGE:
  77.         case HWRITEMESSAGE:
  78.         case HITTESTMESSAGE:
  79.         case GETBBOXMESSAGE:
  80.         case SETBBOXMESSAGE:
  81.         case SECTBBOXMESSAGE:
  82.         case TARGETMESSAGE:
  83.         case CLICKMESSAGE:
  84.         case KEYMESSAGE:
  85.         case SETSELECTMESSAGE:
  86.         case GETSELECTMESSAGE:
  87.         case SIZEMESSAGE:
  88.             return(TRectObj(hndl, message, data));
  89.             break;
  90.  
  91.         case GETRGNMESSAGE:
  92.             rgn = NewRgn();
  93.             OpenRgn();
  94.             rct = mDerefOval(hndl)->oval;
  95.             FrameOval(&rct);
  96.             CloseRgn(rgn);
  97.             return((long)rgn);
  98.             break;
  99.  
  100.         case DRAWMESSAGE:
  101.             rct = mDerefOval(hndl)->oval;
  102.             switch (data) {
  103.                 case DRAWOBJ:
  104.                     FillOval(&rct, &qd.white);
  105.                     FrameOval(&rct);
  106.                     break;
  107.                 case ERASEOBJ:
  108.                     EraseOval(&rct);
  109.                     break;
  110.                 case DRAWSELECT:
  111.                     TRectObj(hndl, message, data);
  112.                     break;
  113.                 case DRAWGHOST:
  114.                     PenMode(patXor);
  115.                     FrameOval(&rct);
  116.                     PenNormal();
  117.                     break;
  118.                 case DRAWMASK:
  119.                     FillOval(&rct, &qd.black);
  120.                     break;
  121.             }
  122.             break;
  123.  
  124.         case PRINTMESSAGE:
  125.             TOvalObj(hndl, DRAWMESSAGE, DRAWOBJ);
  126.             break;
  127.  
  128. #if VH_VERSION
  129.         case VHMESSAGE:
  130.             cptr = ((VHFormatDataPtr)data)->data;
  131.             ccatchr(cptr, 13, 2);
  132.             ccat   (cptr, "$10: TOvalObj:");
  133.             ccatchr(cptr, 13, 1);
  134.             ccat   (cptr, "  $00: selected = ");
  135.             ccatdec(cptr, mDerefOval(hndl)->selected);
  136.             ccatchr(cptr, 13, 1);
  137.             rct = mDerefOval(hndl)->oval;
  138.             ccat   (cptr, "  $02: oval     = ($");
  139.             ccathex(cptr, 0, 4, 4, rct.top);
  140.             ccat   (cptr, ",$");
  141.             ccathex(cptr, 0, 4, 4, rct.left);
  142.             ccat   (cptr, ",$");
  143.             ccathex(cptr, 0, 4, 4, rct.bottom);
  144.             ccat   (cptr, ",$");
  145.             ccathex(cptr, 0, 4, 4, rct.right);
  146.             ccat   (cptr, ")");
  147.             return(true);
  148.             break;
  149. #endif
  150.  
  151.         default:
  152.             break;
  153.     }
  154.  
  155.     return(noErr);
  156. }
  157.  
  158.  
  159.  
  160.